package com.william.springsecurity.controller;

import com.william.springsecurity.common.Result;
import com.william.springsecurity.pojo.SysUser;
import com.william.springsecurity.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author xinchuang
 * @version v1.0
 * @date 2021/12/24 17:26
 * @since Copyright(c) 好心情医疗科技
 */
@RestController
@RequestMapping
public class LoginController {

    @Autowired
    private UserService userService;


    @GetMapping(value = "/getCaptcha")
    public Result getCaptcha(){
        // key code
        String key = UUID.randomUUID().toString();
//        String code =

        return Result.success("success");
    }

    // body传递用户名 密码
    @PostMapping(value = "/login")
    public SysUser login(String username){
        System.out.println("登录");
        UserDetails userDetails = userService.loadUserByUsername(username);
        return null;
    }
}